#include <stdio.h>
#include <math.h>
int isPrime(int n)
{
	if (n==2 || n==3 || n==5 || n==7)return 1;
	if (n==1 || n%2 == 0 || n%3== 0)return 0;
	int i;
	for (i=5; i<=floor(sqrt(n)); i+=6)
		if (n%i== 0 || n%(i+2) == 0)return 0;
	return 1;
}

int main()
{
	int i=35, j, p=2, flag = 0;
	while (1) {
		if (!isPrime(i)) {
			j=1;
			while(j<sqrt(i/2)) {
				p = i-2*j*j;
				//printf("%d ", p);
				if (isPrime(p)) {flag = 1; break;}
				j++;
				
			}
			if (!flag)break;
			flag = 0;
		}
		i+=2;
	}
	printf("%d\n", i);
}
